package com.treasure.mall.zbqmallapi.vo.marketing;

import com.treasure.mall.biz.entity.marketing.RedPacketPO;
import com.treasure.mall.biz.vo.BaseVO;
import com.treasure.mall.zbq.common.Jsr310Utils;
import com.treasure.mall.zbq.common.ienum.marketing.RedPacketEnums;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/8/3
 */
@Data
@NoArgsConstructor
public class RedPacketVO implements BaseVO {
    private static final long serialVersionUID = -3493227941535109129L;

    private Long id;
    private String title;
    private Long merchantId;
    private String merchantName;
    /**
     * 红包金额
     */
    private BigDecimal amount;
    /**
     * 已抢的金额
     */
    private BigDecimal grabAmount;
    /**
     * 红包背景图
     */
    private String backPic;
    /**
     * 红包个数
     */
    private int num;
    private int grabNum;
    private RedPacketEnums.Status status;
    private RedPacketEnums.Type type;
    private String startTime;
    private boolean enabled;
    /**
     * 当前登录用户是否已抢
     */
    private boolean userGrabbed;
    /**
     * 当前时间
     */
    private String currentTime;

    public RedPacketVO(RedPacketPO po) {
        this.id = po.getId();
        this.title = po.getTitle();
        this.merchantId = po.getMerchantPO().getMerchantId();
        this.merchantName = po.getMerchantPO().getData().getTitle();
        this.amount = po.getAmount();
        this.backPic = po.getBackPic();
        this.grabAmount = po.getGrabAmount();
        this.num = po.getNum();
        this.grabNum = po.getGrabNum();
        this.status = po.getStatus();
        this.type = po.getType();
        this.startTime = Jsr310Utils.DateTime.asString(po.getStartTime());
        this.enabled = po.isEnabled();
        this.currentTime = Jsr310Utils.DateTime.asString(LocalDateTime.now());
    }
}
